package com.atguigu.gulimall.member.controller;

import com.atguigu.common.utils.R;
import com.atguigu.gulimall.member.entity.TestUser;
import com.atguigu.gulimall.member.service.TestUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

/**
  *@Dsecriiption TODO
  *@Author liwang
  *@version 2022/9/3、17:40
**/
@Slf4j
@RestController
@RequestMapping("/v1/user")
public class TestUserController {

    @Autowired
    private TestUserService testUserService;

    @PostMapping("/amount")
    R update(@RequestBody TestUser testUser){
        log.info("扣除账户余额开始");
        try {
            TimeUnit.SECONDS.sleep(10);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        testUserService.updateByPrimaryKey(testUser);
        log.info("扣除账户余额结束");
        return R.ok();
    }

}
